//
// Created by lixiao on 2022/03/24.
//


#include "iostream"
#include "gui_client/gui_client.h" //TODO: 用IMPL方式简化头文件，这个头文件包含的东西太多了
#include <boost/bind/bind.hpp>

using namespace std;

class InterfaceImpl : gui::Interface{
public:
    void on_pass_arg(int x, std::string str) override {
      std::cout << "I receive msg from gui::interface with args : "
                << x << " " << str << std::endl;
    }
    void on_heartbeat() override {
      std::cout << "I receive heartbeat!" << std::endl;
    }
};

int main(int argc, char * argv[]){
    my_math_lib::Complex<int> a(12,30);
    my_math_lib::Complex<int> b(2,10);
    my_math_lib::Complex<int> c = a + b;

    std::cout << c << std::endl;

    rclcpp::init(argc, argv);
    auto gui_client = std::make_shared<gui::Client>();
    auto gui_client_node =  gui_client->get_node();
    InterfaceImpl impl;
    auto result = gui_client->get_sum(1,4);
    gui_client->connect_pass_arg_func(boost::bind(&InterfaceImpl::on_pass_arg,&impl,_1,_2));
    gui_client->connect_heartbeat_func(boost::bind(&InterfaceImpl::on_heartbeat,&impl));
    rclcpp::spin(gui_client_node);
    rclcpp::shutdown();



    return 0;
}
